<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>专家审核列表</title>
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <script src="../../res/js/jquery-3.4.1.min.js" type="text/javascript"
            charset="utf-8"></script>
    <script src="../../js/login_common.js" charset="utf-8"></script>
    <script src="../../layui/layui.js" charset="utf-8"></script>
    <script>
        $.ajaxSetup({
            async : false
        });
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            //常规用法
            laydate.render({
                elem: '#stime'
                ,type: 'datetime'
            });
            //常规用法
            laydate.render({
                elem: '#etime'
                ,type: 'datetime'
            });
        });
        $(function(){
            $("#seachTable").on("click",function(){
                //执行重载
                //带条件查询
                table2.reload({
                    url: '../../../RecoveryAtsSchemeController/selectExperttwo',
                    where: {
                        saName: $("#saName").val(),
                        stime: $("#stime").val(),
                        etime: $("#etime").val()
                    },
                    page: { curr: 1 }
                });
            })
        });
    </script>
</head>
<body style="padding: 5px;">
<div class="demoTable">
    搜索：
    <div class="layui-inline">
        <input class="layui-input" name="saName" id="saName" placeholder="方案关键字搜索" autocomplete="off">
    </div>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" id="stime" name="stime" placeholder="请输入开始日期" >
    </div>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" id="etime" name="etime"  placeholder="请输入结束日期" >
    </div>
    <input type="button" id="seachTable" class="layui-btn layui-btn-normal" value="搜索" />
</div>
    <table class="layui-hide" id="test" lay-filter="test"></table>

    <script>

        var table2=null;
        layui.use('table', function(){
            var table = layui.table;
            table2= table.render({
                elem: '#test'
                ,url:'../../../RecoveryAtsSchemeController/selectExperttwo'
                ,toolbar: '#toolbarDemo'
                ,title: '审核方案'
                ,cols: [[
                    {field:'saName', title:'方案名称', width:160}
                    ,{toolbar: '#state', title:'审核状态', width:150}
                    ,{field:'creater', title:'创建人', width:120, sort: true}
                    ,{field:'creatTime', title:'创建时间', width:160}
                    ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:220}
                ]]
                ,page: true//开启分页
            });
            //监听行工具事件
            table.on('tool(test)', function(obj){
                var data = obj.data;
                //console.log(obj)
                if(obj.event === 'edit'){
                    var data1 = obj.data;//获取当前行
                    //iframe层
                    layer.open({
                        type: 2,
                        title: '专家回复页面',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['40%', '50%'],
                        content: 'RecoveryAtsSchemeExpertone.html?id='+data1.schemeId, //iframe的url
                        end:function(){
                            table2.reload();
                        }
                    });
                }else if(obj.event === 'one'){
                    var data1 = obj.data;//获取当前行
                    var url="../../../RecoveryAtsSchemeController/selectExpertState";
                    var data={seId:data1.seId};
                    $.post(url,data,function(obj){
                        if(obj.auditState=="40"){
                            layer.msg("已回复!不能进行此操作",{icon: 8})
                            return false;
                        }else if(obj.auditState=="30"){
                            layer.msg("已成你待回复操作!无需重复操作",{icon: 8})
                            return false;
                        }else if(obj.auditState=="30"){
                            layer.msg("已成你待回复操作!无需重复操作",{icon: 8})
                            return false;
                        }else if(obj.auditState=="20"){
                            var urll="../../../RecoveryAtsSchemeController/updateExpertState";
                            var datal={schemeId:data1.schemeId};
                            $.post(urll,datal,function(obj){
                                if(obj.num===1){
                                    layer.msg(obj.msg, {
                                        icon: 6,
                                        time: 1000
                                    }, function () {
                                        window.location.reload();
                                    });
                                }
                            },"json");
                        }
                    },"json");
                }

            });

        });
    </script>
<script type="text/html" id="barDemo">
    {{#
    if(d.auditState == "20" ||d.auditState == "30" ){

    }}
    <a class="layui-btn layui-btn-xs" lay-event="edit">回复方案</a>
    <a class="layui-btn layui-bg-orange layui-btn-xs" lay-event="one">点我成待回复状态</a>
    {{# }else{ }}
    <button class="layui-btn layui-btn-disabled layui-btn-xs layui-icon layui-icon-reply-fill" lay-event="edit" disabled="disabled">回复方案</button>
    <button class="layui-btn layui-btn-disabled layui-btn-xs layui-icon layui-icon-reply-fill" lay-event="one" disabled="disabled">点我成待回复状态</button>
    {{# } }}
</script>
<script type="text/html" id="state">
    {{#
    if(d.auditState == "10" ){

    }}
    <h5 style="color: aqua">申请</h5>
    {{# } }}
    {{#
    if(d.auditState == "20" ){

    }}
    <h5 style="color: #00F7DE">中心领导已同意</h5>
    {{# } }}
    {{#
    if(d.auditState == "21" ){

    }}
    <h5 style="color: red">中心领导不同意</h5>
    {{# } }}
    {{#
    if(d.auditState == "30" ){

    }}
    <h5 style="color: #2D93CA">专家已获知待回复</h5>
    {{# } }}
    {{#
    if(d.auditState == "40" ){

    }}
    <h5 style="color: #0C78DD">专家已回复</h5>
    {{# } }}
</script>
</body>
</html>